import Router from 'vue-router'
import Index from '@/components/Index'
import in_page from '@/components/in_page.vue'
import OutPage from '@/components/OutPage'
import ManagePage from '@/components/ManagePage'
import Login from  '@/components/login'
import in_list from "@/components/in_list"

const in_page_e = r => require.ensure([], () => r(require('@/components/in_page_e.vue'), "group-foo"));
const purchase_note = r => require.ensure([], () => r(require('@/components/purchase_note.vue')), 'group-foo');
// const  in_list = r => require.ensure([], () => r(require('@/components/in_list.vue'), "group-foo"));

export default new Router({
  routes: [
    {
      path: '/index',
      meta: {
        requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
      },
      name: 'Index',
      component: Index,
      redirect: {name: 'InPage'},
      children: [
        {
          // 当 /user/:id/profile 匹配成功，
          // UserProfile 会被渲染在 User 的 <router-view> 中
          path: 'in_page',
          component: in_page,
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          }

        },

        {
          path: "purchase_note",
          component: purchase_note,
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          },
          // alias:"in"
        },
        {
          path: "in_page_e",
          component: in_page_e,
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          }
        },
        {
          path: 'out',
          name: 'OutPage',
          component: OutPage,
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          }
        },
        {
          path: 'in',
          name: 'InPage',
          component: in_page,
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          },
          children:[
            {
              path: 'in_list',
              name: 'in_list',
              component: in_list,
              meta: {
                requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
              }
            }
          ]

        },
        {
          path: 'manage',
          name: 'ManagePage',
          component: ManagePage,
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          }
        },
      ]
    },
    {
      path: '/',
      name: 'Login',
      component: Login,
    }
  ]
})
